package com.xhy.major.controller;

import com.xhy.major.pojo.Major;
import com.xhy.major.service.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class MajorController {
    @Autowired
    MajorService majorService;
    //查询用户
    @GetMapping("/major")
    public List<Major> queryMajorList(){
        List<Major> major = majorService.selectMajor();
        return major;
    }
    //添加用户
    @PostMapping("/addMajor")
    public String addMajor(Major major){
        majorService.addMajor(major);
        return "ok";
    }
    //修改用户
    @PutMapping("/updateMajor")
    public String updateMajor(Major major) {
        majorService.updateMajor(major);
        return "ok";
    }
    @DeleteMapping("/deleteMajor")
    public String deleteMajor(int id){
        majorService.deleteMajor(id);
        return "ok";
    }
}
